<?php $this->load->module('mobile/index/header', array());?>
<script type="text/javascript">
    //调用微信JS api 支付
    function jsApiCall()
    {
        WeixinJSBridge.invoke(
            'getBrandWCPayRequest',
            <?php echo $jsApiParameters; ?>,
            function(res){
               /*WeixinJSBridge.log(res.err_msg);
                alert(res.err_code+res.err_desc+res.err_msg);*/
            }
        );
    }

    function callpay()
    {
        if (typeof WeixinJSBridge == "undefined"){
            if( document.addEventListener ){
                document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
            }else if (document.attachEvent){
                document.attachEvent('WeixinJSBridgeReady', jsApiCall);
                document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
            }
        }else{
            jsApiCall();
        }
    }
</script>
<script type="text/javascript">
    //获取共享地址
   /* function editAddress()
    {
        WeixinJSBridge.invoke(
            'editAddress',
            <?php  //echo $editAddress; ?>,
            function(res){
                var value1 = res.proviceFirstStageName;
                var value2 = res.addressCitySecondStageName;
                var value3 = res.addressCountiesThirdStageName;
                var value4 = res.addressDetailInfo;
                var tel = res.telNumber;

                alert(value1 + value2 + value3 + value4 + ":" + tel);
            }
        );
    }
*/
    /*window.onload = function(){
        if (typeof WeixinJSBridge == "undefined"){
            if( document.addEventListener ){
                document.addEventListener('WeixinJSBridgeReady', editAddress, false);
            }else if (document.attachEvent){
                document.attachEvent('WeixinJSBridgeReady', editAddress);
                document.attachEvent('onWeixinJSBridgeReady', editAddress);
            }
        }else{
            editAddress();
        }
    };*/
   callpay();
</script>
<style>
    .chengjiren-price input[type="button"] {
        width: 60%;
        height: 2rem;
        margin-top: 0.5rem;
        background-color:#349cd1!important;
        border-radius: 5px;
        color: #ffffff;
        font-size: 1rem;
        font-weight: bold;
    }
    .linegrey{margin-bottom:0!important;}
</style>

<div class="content">
    <div id="list">

        <div class="list-item fn-clear">
            <div class="info">
                <h5><?php echo $info['name'] ?$info['name'] :$info['order_title'];?></h5>
                <div class="i-note">

                    <p class="price">
                        <?php if (!empty($info['order_account'])) :?>
                            ¥<?php echo ($info['order_account']);?>
                        <?php endif; ?>
                    </p>
                    <p class="c_mt">订单编号：<?php echo $info['order_sn'];?></p>
                    <p class="c_mt">入住人数：<?php echo $info['order_num'];?></p>
                    <p class="c_mt">入住时间：<?php echo $info['start_date'];?></p>
                    <p class="c_mt">离店时间：<?php echo $info['end_date'];?></p>
                    <p class="c_mt">下单时间：<?php echo $info['add_time'];?></p>
                </div>
            </div>

        </div>

    </div>
    <div class="linegrey"></div>
    <div class="col_div">
        <a href="<?php echo $info['redirect'];?>" class="btn btn-orange" title="支付完成">支付完成</a>
    </div>

    <div class="col_div">
        <a href="javascript:;" class="btn btn-blue" onclick="callpay()"  title="支付失败">支付失败</a>
    </div>
</div>
<script>
    var check_url = '<?php echo $check_url;?>' ;
    var redirect = '<?php echo $info['redirect'];?>' ;
    setInterval(function(){
        $.post(check_url, {}, function (data) {
            var json = eval("(" + data + ")");
            if (json['status'] == '1' && json['msg'] == 'success') {
                window.location.href = redirect;
            }
        })
    },3000)
</script>
<?php $this->load->module('mobile/index/footer', array());?>
